// 请求方法
const HTTP = require("../../utils/http-list.js");
const http = new HTTP();

//getApp()的数据
let app=getApp();
let gd = app.globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detail:"",
    address:{address:"",phone:"",name:"",provinceCityArea:"/"},
    list:"",
    id:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id:options.cid
    })
    http.showLoading().postD({
      cmd:"getOrderById",
      id:options.cid,//订单id
      uid:gd.userId ,
    }).then((res)=>{
       
      if(res.data.result==0){
        let data=res.data;
        let list={
          dingdanbianhao:data.orderNum,
          dingdanzongjia:data.orderMoney,
          huiyuanlijian:data.discountMoney,
          xiadanshijian:data.addTime,
          shangmenshijian:data.homeTime,
          wangongshijian:data.completedTime,
          zhifushijian:data.payTime
        }
        this.setData({
          detail:res.data,
          "address.address":data.address,
          "address.phone":data.phone,
          "address.name":data.name,
          list:list
        })
        wx.hideLoading();
      }else{
        wx.hideLoading();
        http.showToast(res.data.resultNote)
      }
    })
  },
  /**
   * 拨打电话
   */
  call(){
    let phone=this.data.detail.masterPhone;
    wx.makePhoneCall({
      phoneNumber:phone
    })
  },
  goquxiao(){
    wx.navigateTo({
      url:"/pages/quxiaoorder/quxiaoorder?cid="+this.data.id
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  goList(){
    wx.navigateTo({
      url:"/pages/cailiaolist/cailiaolist?cid="+this.data.id
    })
  },
  /**
   * 售后
   */
  gosh(){
    wx.navigateTo({
      url:"/pages/shouhou/shouhou?cid="+this.data.id
    })
  },
  /**
   * 
   */
  gozhifu(event) {
    wx.navigateTo({
      url: "/pages/pay/pay?cid=" + this.data.id
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})